﻿@model List<InfoReply>
@{
    ViewData["Title"] = "详情";
    InfoBlog Item = (InfoBlog)ViewBag.Item;
}

<h4>@Item.Title</h4>
<table id="TMain" class="table table-striped">
    <tr><td>@Item.Content</td><td>@Item.UserName</td></tr>
    @foreach (var ii in Model)
    {
        <tr>
            <td>@ii.Content</td>
            <td >@ii.UserName</td>
        </tr>
    }
</table>

@if (User.Identity.IsAuthenticated)
{
<textarea id="TextArea1" rows="10" class="form-control"></textarea>
    <button onclick="Reply()" class="btn btn-primary">回复</button>
}
else
{
    <a asp-action="Login" asp-controller="Account">登录</a>
}


@section scripts
{
    <script>
        function Reply() {
            var c = $("#TextArea1").val();
            if (c == "") {
                ShowMessage("请输入一些内容");
                return;
            }
            CallAjax("@Url.Action("Save")", { id:@Item.ID, content: c}, function () {
                $("#TMain").append(`<tr><td>${c}</td><td  >${"@User.Identity.Name"}</td></tr>`)
                $("#TextArea1").val("");
            });
        }
    </script>

}